package O2.basic;

public class CalcFloat {

    public static void main(String[] args) {
        float f1 = 1/4.0f;
        float f2 = 1/4.0f;

        float f3 = 0.1f;
        float f4 = 0.2f;

        System.out.println(f1 + f2);
        System.out.println(f3 + f4);

        double x = 1.0 / 10;
        double y = 1 - 9.0 / 10;
        // 观察x和y是否相等:
        System.out.println(x);
        System.out.println(y);

        double a = 1.0;
        double b = 3.0;
        double c = -4.0;
        double s = Math.sqrt(b*b-4*a*c);
        double r1 = (-b+s)/2;
        double r2 = (-b-s)/2;
        System.out.println(r1);
        System.out.println(r2);
        System.out.println(r1 == 1 && r2 == -4 ? "测试通过" : "测试失败");


    }

}
